package com.cloud.bc.service.impl;

import com.cloud.bc.model.entity.BcUserBankcards;
import com.cloud.bc.mapper.BcUserBankcardsMapper;
import com.cloud.bc.service.BcUserBankcardsService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.List;

/**
 * 用户提现账号
 *
 * @author douhaichao code generator
 * @date 2021-02-05 11:11:47
 */
@Service
@AllArgsConstructor
public class BcUserBankcardsServiceImpl extends ServiceImpl<BcUserBankcardsMapper, BcUserBankcards> implements BcUserBankcardsService {

    /**
   * 根据对象属性查找满足条件的第一条数据     *      * @return
   */
    @Override
    public BcUserBankcards selectOne(BcUserBankcards req) {
        QueryWrapper queryWrapper = new QueryWrapper<BcUserBankcards>();
        queryWrapper.setEntity(req);
        return baseMapper.selectOne(queryWrapper);
    }

    /**
     * 根据条件查询所有
     */
    @Override
    public List<BcUserBankcards> selectAll(BcUserBankcards req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(req);
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 根据对象查询所有分页数据(精确查询)     *      * @return
     */
    @Override
    public IPage<BcUserBankcards> selectPage(Page page, BcUserBankcards req) {
        IPage<BcUserBankcards> list = baseMapper.selectPage(
                page,
                new QueryWrapper<BcUserBankcards>().setEntity(req));
        return list;
    }

    /**
     * 根据对象查询所有分页数据(模糊查询)     *      * @return
     */
    @Override
    public IPage<BcUserBankcards> selectPageByLike(Page page, BcUserBankcards req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        
                                        if (null !=req.getId()) {
                    queryWrapper.eq("id" , req.getId());
                }
                    
                                        if (null !=req.getUserId()) {
                    queryWrapper.eq("user_id" , req.getUserId());
                }
                    
                            if (!StrUtil.isEmpty(req.getWay())) {
                    queryWrapper.like("way" , req.getWay());
                }
                                
                            if (!StrUtil.isEmpty(req.getName())) {
                    queryWrapper.like("name" , req.getName());
                }
                                
                            if (!StrUtil.isEmpty(req.getNumber())) {
                    queryWrapper.like("number" , req.getNumber());
                }
                                
                            if (!StrUtil.isEmpty(req.getData())) {
                    queryWrapper.like("data" , req.getData());
                }
                                
                                        if (null !=req.getCreatedAt()) {
                    queryWrapper.eq("created_at" , req.getCreatedAt());
                }
                    
                                        if (null !=req.getUpdatedAt()) {
                    queryWrapper.eq("updated_at" , req.getUpdatedAt());
                }
                            IPage<BcUserBankcards> list = baseMapper.selectPage(page, queryWrapper);
        return list;
    }

    /**
     * 根据条件统计数据量     *      * @return
     */
    @Override
    public int count(BcUserBankcards req) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(req);
        return baseMapper.selectCount(queryWrapper);
    }
}
